package redisinit

import (
	"api/appconfig"
	"fmt"
	"github.com/go-redis/redis"
)

var (
	RedisClient *redis.Client
	err         error
)

func RedisInit() {
	RedisClient = redis.NewClient(&redis.Options{
		Addr:     appconfig.AppConf.RedisConfig.Addr,
		Password: appconfig.AppConf.RedisConfig.Password, // no password set
		DB:       appconfig.AppConf.RedisConfig.Db,       // use default DB
	})

	_, err = RedisClient.Ping().Result()
	if err != nil {
		fmt.Println("redis连接信息失败", err)
		return
	}
	fmt.Println("redis连接信息成功")
}
